package com.atcd.springboot2.config;


import com.atcd.springboot2.intercepter.LoginInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration //配置定制化
public class AdminLoginConfig implements WebMvcConfigurer {


    //配置拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //      /**的意思是所有文件夹及里面的子文件夹(拦截所有)
       registry.addInterceptor(new LoginInterceptor()).
               addPathPatterns("/**"). //  /**也会把静态资源也会被拦截(css js...)
               excludePathPatterns("/","/login","/static/css");//除了那些不拦截,也要放行css js ....

//        registry.addInterceptor() 可以配置多个拦截器，而且addInterceptor()里面还可以加入一个redis的拦截器功能
    }
}
